/************************* 版权声明 *********************************
 * 
 * 版权所有：Apache License 2.0
 * 
 ************************* 版本声明 *********************************
 *@since jdk1.5
 *@version 0.1
 ************************* 变更记录 *********************************
 *
 * 创建者：bijiqiang Email:bijiqiang@gmail.com   创建日期： 2009-12-28
 * 创建记录：创建类结构。
 * 
 * 修改者：       修改日期：
 * 修改记录：
 *
 * 修改者：       修改日期：
 * 修改记录：
 * ……
 ************************* To  Do *********************************
 *
 * 1、实现所有未实现的方法（抛出UnsupportedOperationException的方法）。
 * 
 ************************* 随   笔 *********************************
 *
 * 
 * 
 ******************************************************************
 */
package com.realgodo.site.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;

import com.realgodo.site.entity.application.show.Show;
import com.realgodo.site.entity.application.show.ShowCatalog;
import com.realgodo.site.entity.security.User;
import com.realgodo.site.entity.site.Info;
import com.realgodo.site.service.UserManager;
import com.realgodo.site.service.application.ShowCatalogManager;
import com.realgodo.site.service.application.ShowManager;
import com.realgodo.site.service.site.InfoManager;

public class IndexController extends ControllerSupport {

	/***/
	private static final long serialVersionUID = -788932584974186390L;
	@Autowired
	private UserManager userManager;
	@Autowired
	private ShowManager showManager;
	@Autowired
	private InfoManager infoManager;
	@Autowired
	private ShowCatalogManager showCatalogManager;

	private Page<User> manPage = new Page<User>(12);
	private Page<User> memberPage = new Page<User>(12);
	private Page<Show> showPage = new Page<Show>(5);
	private Page<Info> infoPage = new Page<Info>(4);
	private Page<Show> viedoPage = new Page<Show>(4);
	private Show topViedo;

	public String index() {
		Show showForm = new Show();
		showForm.setTop(Show.TOP_YES);
		showForm.setViedo(Show.VIEDO_NOT);
		showForm.setPrivacy(Show.PRIVACY_PUBLIC);
		showPage = this.showManager.findShows(showPage, showForm);

		User manForm = new User();
		manForm.setEnable(User.ENABLED_DISENABLED_ALL);
		manForm.setMeiMeiMan(User.MEIMEI_MAN_YES);
		manForm.setMeiMeiMember(User.MEIMEI_MEMBER_ALL);
		manForm.setRecommend(User.RECOMMEND_ALL);
		manPage = this.userManager.findUsers(manPage, manForm);

		User memberForm = new User();
		memberForm.setEnable(User.ENABLED_DISENABLED_ALL);
		memberForm.setMeiMeiMan(User.MEIMEI_MAN_ALL);
		memberForm.setMeiMeiMember(User.MEIMEI_MEMBER_YES);
		memberForm.setRecommend(User.RECOMMEND_ALL);
		memberPage = this.userManager.findUsers(memberPage, memberForm);

		Show viedoForm = new Show();

		viedoForm.setViedo(Show.VIEDO_YES);
		viedoForm.setTop(Show.TOP_YES);
		viedoForm.setPrivacy(Show.PRIVACY_PUBLIC);
		viedoPage = this.showManager.findShows(viedoPage, viedoForm);

		topViedo = showManager.findTopShowViedo();

		super.getParamMap().put("status", String.valueOf(Info.STATUS_PUB));
		this.infoPage = infoManager.find(4, super.getParamMap());
		return "index";
	}

	public Page<User> getManPage() {
		return manPage;
	}

	public void setManPage(Page<User> manPage) {
		this.manPage = manPage;
	}

	public Page<User> getMemberPage() {
		return memberPage;
	}

	public void setMemberPage(Page<User> memberPage) {
		this.memberPage = memberPage;
	}

	public Page<Show> getShowPage() {
		return showPage;
	}

	public void setShowPage(Page<Show> showPage) {
		this.showPage = showPage;
	}

	public Page<Info> getInfoPage() {
		return infoPage;
	}

	public List<ShowCatalog> getShowCatalogs() {
		Page<ShowCatalog> showCatalogPage = new Page<ShowCatalog>(15);
		return this.showCatalogManager.findShowCatalogs(showCatalogPage)
				.getResult();
	}

	public Page<Show> getViedoPage() {
		return viedoPage;
	}

	public void setViedoPage(Page<Show> viedoPage) {
		this.viedoPage = viedoPage;
	}

	public Show getTopViedo() {
		return topViedo;
	}

	public void setTopViedo(Show topViedo) {
		this.topViedo = topViedo;
	}

}
